﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Models;
using System.Collections.Generic;
using BLL;

namespace PCCS.Management.AdminManage
{
    public partial class AdminLog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDataForGridView();
            }
        }

        private void BindDataForGridView()
        {
            IList<Models.AdminLog> log = AdminLogManager.GetAllAdminLogs();
            this.AspNetPager1.RecordCount = log.Count;
            this.AspNetPager1.PageSize = 20;
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = log;
            pds.AllowPaging = true;
            pds.PageSize = 20;
            pds.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex - 1;
            gvAdminLog.DataSource = pds;
            gvAdminLog.DataBind();
        }

        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            BindDataForGridView();
        }


        protected void lbDel_Click(object sender, EventArgs e)
        {
            for (int index = 0; index < gvAdminLog.Rows.Count; index++)
            {
                if (((CheckBox)gvAdminLog.Rows[index].FindControl("chkSelect")).Checked == true)
                {
                    int Id = (Convert.ToInt32(((Label)gvAdminLog.Rows[index].FindControl("lblId")).Text));
                    AdminLogManager.DeleteAdminLogByLogID(Id);
                }
            }
            BindDataForGridView();
        }
    }
}
